# 该用例到该目录执行run.sh
USER_NAME=`whoami`
ENTRY_FILE="ani_namespace"
DEPENCE_FILE="@depence.d"
export PANDA_HOME="/mnt/data/${USER_NAME}/openharmony/arkcompiler_1108_new/runtime_core/static_core/build" # 指向构建产物目录
gcc -o lib$ENTRY_FILE.so --shared -fPIC $ENTRY_FILE.cpp -I $PANDA_HOME/../plugins/ets/runtime/ani # 编译so
mv lib$ENTRY_FILE.so ../build/output

# 编译abc
echo "================build start!================"
cd /mnt/data/${USER_NAME}/ani_cookbook/$ENTRY_FILE && /mnt/data/${USER_NAME}/openharmony/arkcompiler_1108_new/runtime_core/static_core/build/bin/es2panda $ENTRY_FILE.ets --output /mnt/data/${USER_NAME}/ani_cookbook/build/output/$ENTRY_FILE.abc # --extension sts
cd /mnt/data/${USER_NAME}/ani_cookbook/$ENTRY_FILE && /mnt/data/${USER_NAME}/openharmony/arkcompiler_1108_new/runtime_core/static_core/build/bin/es2panda $DEPENCE_FILE.ets  --output /mnt/data/${USER_NAME}/ani_cookbook/build/output/$DEPENCE_FILE.abc # --extension sts
echo "================build end!=================="

cd ..
cd ./build/output
# # 链接abc
echo "================link start!================"
/mnt/data/${USER_NAME}/openharmony/arkcompiler_1108_new/runtime_core/static_core/build/bin/ark_link --output=link.abc --  "/mnt/data/${USER_NAME}/ani_cookbook/build/output/${ENTRY_FILE}.abc" "/mnt/data/${USER_NAME}/ani_cookbook/build/output/${DEPENCE_FILE}.abc" # crash
echo "================link end!================"

# 执行abc
export LD_LIBRARY_PATH=.; /mnt/data/${USER_NAME}/openharmony/arkcompiler_1108_new/runtime_core/static_core/build/bin/ark  --boot-panda-files=/mnt/data/${USER_NAME}/openharmony/arkcompiler_1108_new/runtime_core/static_core/build/plugins/ets/etsstdlib.abc  --load-runtimes=ets link.abc $ENTRY_FILE.ETSGLOBAL::main

# load_run
# export LD_LIBRARY_PATH=.; /mnt/data/${USER_NAME}/openharmony/arkcompiler_1108_new/runtime_core/static_core/build/bin/ark  --boot-panda-files=/mnt/data/${USER_NAME}/openharmony/arkcompiler_1108_new/runtime_core/static_core/build/plugins/ets/etsstdlib.abc  --load-runtimes=ets --panda-files=$DEPENCE_FILE.abc $ENTRY_FILE.abc $ENTRY_FILE.ETSGLOBAL::main